﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Printing;
using System.Drawing;

namespace Notenberechner_C_Sharp
{
    class Drucken_Klasse_C
    {

        public static string data;
      public static string überschrift = "noname";
      public static int abstand = 50;
      public static int cu_px = 300;

      public void drucken()
      {
         
        PrintDialog pdia = new PrintDialog();
        cu_px = 300;
        PrintDocument pd = new PrintDocument();
        pd.DocumentName = überschrift;
          pd.PrintPage +=new PrintPageEventHandler(pd_PrintPage);


          if (pdia.ShowDialog() == DialogResult.OK){
        
            pd.PrinterSettings = pdia.PrinterSettings;
            pd.Print();
        
        }
            

      }

      public object add(string Feld1, string Feld2)
      {
          if (string.IsNullOrEmpty(data))
          {
          }
          else
          {
              data = data + ",";
          }
          data = data + Feld1 + "/" + Feld2;
          return "OK";
      }

      public object add(string Feld1, string Feld2)
      {
          if (string.IsNullOrEmpty(data))
          {
          }
          else
          {
              data = data + ",";
          }
          data = data + Feld1 + "/" + Feld2;
          return "OK";
      }


      public object clear()
      {
          data = "";
          return "OK";
      }

      void pd_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
      {




          e.Graphics.DrawString(überschrift, new Font("Arial", 55, FontStyle.Regular, GraphicsUnit.Pixel), Brushes.Black, new Point(280, 60));
          e.Graphics.DrawLine(Pens.Black, new Point(0, 160), new Point(830, 160));
          e.Graphics.DrawLine(Pens.Black, new Point(0, 161), new Point(830, 161));
          e.Graphics.DrawLine(Pens.Black, new Point(0, 162), new Point(830, 162));
          e.Graphics.DrawLine(Pens.Black, new Point(0, 163), new Point(830, 163));



          string[] dataitem = data.Split(',');

          foreach (string s in dataitem)
          {

              string[] dataArr = s.Split('/');
              var _with1 = e.Graphics;
              _with1.DrawString(dataArr[0], new Font("Arial", 25, FontStyle.Regular, GraphicsUnit.Pixel), Brushes.Black, new Point(150, cu_px));
              _with1.DrawString(dataArr[1], new Font("Arial", 25, FontStyle.Regular, GraphicsUnit.Pixel), Brushes.Black, new Point(475, cu_px));

              cu_px = cu_px + abstand;
          }








      }

      




    }
}
